from django.apps import AppConfig
import sys


class MyAppConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'myApp'

    def ready(self):
        """
        当Django应用准备就绪时，启动定时任务调度器
        """
        # 避免在自动重载或迁移时启动调度器
        if 'runserver' in sys.argv or 'uwsgi' in sys.argv or 'manage.py' not in sys.argv:
            from djangoProject.scheduler import start_scheduler
            start_scheduler()
